const express = require('express')
const userCtrl = require('../controller/user')
const jwtAuthMiddleware = require('../middleware/jwt-auth')

const router = express.Router()

router.get('/users', userCtrl.getUserList)

// 用户注册
router.post('/users', userCtrl.register)

// 用户登录
router.post('/users/login', userCtrl.login)

// 获取当前登录用户
router.get('/user', jwtAuthMiddleware(), userCtrl.getCurrentUser)

// 更新当前登录用户
router.put('/user', jwtAuthMiddleware(), userCtrl.updateCurrentUser)

module.exports = router